Sri Lanka started the day on 24 for 2 in chase of 660.
Mendis stayed unbeaten on 51 at the end of the first session. He also became the second player after Kohli to score more than 1000 runs in Tests in 2018.
He was dismissed for 67 in the second session.
Chandimal and Mathews saw off the second session to take Sri Lanka to 155 for 3.
Mathew injured his hamstring and was forced to retire hurt during the Tea break.
Wagner dismissed Chandimal and Silva in the final session.
New Zealand struck late as Sri Lanka slipped to 231 for 6 still 429 away from a win.